<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('训练成绩录入')"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: bootstrap-select-css"/>
    <th:block th:include="include :: datetimepicker-css"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="data-form">
                <div class="select-list">
                    <li>
                        <label>上课时间: </label>
                        <div class="input-group date">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                            <input id="scheduleTime" name="scheduleTime" type="text" class="col-sm-3 control-label" placeholder="yyyy-MM-dd">
                        </div>
                    </li>
                    <li>
                        <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                class="fa fa-search"></i>&nbsp;搜索</a>
                    </li>

                </div>
            </form>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: bootstrap-select-js"/>
<th:block th:include="include :: datetimepicker-js"/>
<script th:inline="javascript">
    // 权限
    var enteringFlag = [[${@permission.hasPermi('business:scheduleRecord:entering')}]];
    var showFlag = [[${@permission.hasPermi('business:scheduleRecord:enteringShow')}]];

    // 字典
    var startType = [[${@dict.getType('sys_start_type')}]];
    var prefix = ctx + "business/scheduleRecord";

    $(function () {
        layui.use('laydate', function () {
            layui.laydate.render({
                elem: '#scheduleTime',
                value: new Date(),
                format: 'yyyy-MM-dd',
                type: 'date'
            });
        })
    });

    $(function () {
        var options = {
            url: prefix + "/list",
            modalName: "数据",
            columns: [{
                checkbox: true
            },
                {
                    field: 'schoolTime',
                    title: '上课时间',
                },
                {
                    field: 'projectType',
                    title: '课程名称',
                },
                {
                    field: 'studentNames',
                    title: '学员姓名',
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + enteringFlag + '" href="javascript:void(0)" onclick="studentBasics(\'' + row.scheduleTime + "," + row.projectType + '\')"><i class="fa fa-edit"></i>录入</a>');
                        actions.push('<a class="btn btn-success btn-xs ' + showFlag + '" href="javascript:void(0)" onclick="showStudentBasics(\'' + row.scheduleTime + "," + row.projectType + '\')"><i class="fa fa-edit"></i>查看</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function studentBasics(data) {
        var arr = data.split(",");
        var projectType;
        if (arr[1] == "认知") {
            projectType = 1;
        }
        var url = prefix + "/studentBasics/" + arr[0] + "/" + projectType;
        $.modal.openTab("录入", url);
    }

    function showStudentBasics(data) {
        var arr = data.split(",");
        var projectType;
        if (arr[1] == "认知") {
            projectType = 1;
        }
        var url = prefix + "/studentBasicsShow/" + arr[0] + "/" + projectType;
        $.modal.openTab("查看", url);
    }

</script>
</body>

</html>